//
//  SSHSession.h
//  tunneltool
//
//  Created by Andreas Hindborg on 12/05/11.
//  Copyright 2011 Andreas Hindborg. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import <libssh2.h>
#import "SSHTunnel.h"

@protocol SSHPasswordDelegate
-(NSString*) passwordCallback;
@end

@protocol SSHKeyboardInteractiveDelegate
-(NSString*) keyboardInteractiveCallback:(NSString*)message;
@end

@interface SSHSession : NSObject {
    @private NSString *remoteIP;
    @private uint32_t remotePort;

    @private NSString *user;
    @private NSString *publicKeyPath;
    @private NSString *privateKeyPath;


    @private LIBSSH2_SESSION *session;
    @private int sessionSocket;

    @private NSMutableSet *tunnels;
    @private bool connected;

    @private id <SSHPasswordDelegate> passwordDelegate;
    @private id <SSHKeyboardInteractiveDelegate> keyboardInteractiveDelegate;

}

@property (readwrite, retain) NSString *user;
@property (readwrite, retain) NSString *publicKeyPath;
@property (readwrite, retain) NSString *privateKeyPath;
@property (readonly) int sessionSocket;
@property (readonly) LIBSSH2_SESSION *session;
@property (readonly) bool connected;
@property (readwrite, retain) id <SSHPasswordDelegate> passwordDelegate;

- (SSHSession*) initWithRemoteIP: (NSString*)ip remotePort: (uint32_t)port;

- (int) connect;

- (int) close;

- (LIBSSH2_SESSION*) getSession;

- (SSHTunnel*) createTunnelWithLocalIP:(NSString*) aLocalIP
                             localPort:(uint32_t) aLocalPort
                              remoteIP:(NSString*) aRemoteIP
                            remotePort: (uint32_t) aRemotePort;

@end

